/**
 * testowanie
 */
package czolgisci;

import java.awt.Component;

import utils.input.KeyboardListener;
import utils.time.Clock;
import utils.time.IClockListener;
import czolgisci.display.DisplayManager;
import czolgisci.display.GraphicInterface;
import czolgisci.events.TickEvent;
import czolgisci.map.Map;
import czolgisci.map.MapManager;
import czolgisci.tiles.factory.StandardTileFactory;

/**
 * @author kasztan no! singleton - przerobić
 */
public class Engine implements IClockListener
{

	private static Engine instance;

	private GraphicInterface rootFrame;

	private LifeManager playerLifesManager;

	private KeyboardListener keyListener;

	private MapManager tilesManager;

	static public Engine getInstance()
	{
		instance = new Engine();
		return instance;
	}

	private Clock interval;

	// smietnik totalny, trzeba przerobic
	private Engine()
	{
		//init( null, null, new String[2]);
		rootFrame = null;
		rootFrame.getAlignmentX();
		keyListener = new KeyboardListener(rootFrame);
		playerLifesManager = new LifeManager();
		tilesManager = new MapManager(new Map(10, 10, new char[10][10]),
				new StandardTileFactory());
		DisplayManager.getInstance().init(tilesManager.iterator(), null);
		interval = new Clock();

	}

	private void attachImages()
	{
	}

	public void destroy()
	{

	}

	public void init(GraphicInterface root, Component drawingArea,
			String playerNamesArr[])
	{
		rootFrame = root;
		rootFrame.getAlignmentX();
		keyListener = new KeyboardListener(root);
		playerLifesManager = new LifeManager();
		tilesManager = new MapManager(new Map(10, 10, new char[10][10]),
				new StandardTileFactory());
		DisplayManager.getInstance().init(tilesManager.iterator(), drawingArea);
		interval = new Clock();

		attachImages();
		registerKeys();

		playerLifesManager.addPlayer("aaa", 123);

		interval.start(0, 10);

	}

	public void onTankDestroy(String name)
	{

	}

	public void onTick(TickEvent e)
	{
		// TODO Auto-generated method stub

	}

	public void pause()
	{

	}

	public void refresh()
	{

	}

	private void registerKeys()
	{
		keyListener.getClass();
		tilesManager.getTileFromIJ(10, 10);
		// keyListener.registerKey(key, instance, callback, arguments)
	}

	public void resume()
	{

	}

	public void start()
	{

	}

}
